We've long had double precision mouse coordinates on wayland (e.g.
when rotating a window) but with the new scaling we even have it on
X (and, its also in Xinput2), so convert all the internal mouse/device
position getters to use doubles and add new accessors for the
public APIs that take doubles instead of ints.
GdkCursor *cursor);
static void gdk_broadway_device_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
static void gdk_broadway_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device,
GdkWindow *window,
static void gdk_broadway_device_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_broadway_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_broadway_device_select_window_events (GdkDevice *device,
gdouble *axes,
GdkModifierType *mask)
{
- gint x_int, y_int;
+ gdouble x, y;
- gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
+ gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
- axes[0] = x_int;
- axes[1] = y_int;
+ axes[0] = x;
+ axes[1] = y;
}
}
static void
gdk_broadway_device_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
}
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindow *toplevel;
static GdkWindow *
gdk_broadway_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
static gboolean
gdk_window_broadway_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *child;
#include "gdkinternals.h"
#include "gdkintl.h"
+/* for the use of round() */
+#include "fallback-c89.c"
+
/**
* SECTION:gdkdevice
* @Short_description: Object representing an input device
}
/**
- * gdk_device_get_position:
+ * gdk_device_get_position_double:
* @device: pointer device to query status about.
* @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
* the @device is on, or %NULL.
* @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
* @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
*
- * Gets the current location of @device. As a slave device
+ * Gets the current location of @device in double precision. As a slave device
* coordinates are those of its master pointer, This function
* may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
* unless there is an ongoing grab on them, see gdk_device_grab().
*
- * Since: 3.0
+ * Since: 3.10
**/
void
-gdk_device_get_position (GdkDevice *device,
- GdkScreen **screen,
- gint *x,
- gint *y)
+gdk_device_get_position_double (GdkDevice *device,
+ GdkScreen **screen,
+ gdouble *x,
+ gdouble *y)
{
GdkDisplay *display;
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkScreen *default_screen;
GdkWindow *root;
}
/**
- * gdk_device_get_window_at_position:
+ * gdk_device_get_position:
+ * @device: pointer device to query status about.
+ * @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
+ * the @device is on, or %NULL.
+ * @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
+ * @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
+ *
+ * Gets the current location of @device. As a slave device
+ * coordinates are those of its master pointer, This function
+ * may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
+ *
+ * Since: 3.0
+ **/
+void
+gdk_device_get_position (GdkDevice *device,
+ GdkScreen **screen,
+ gint *x,
+ gint *y)
+{
+ gdouble tmp_x, tmp_y;
+
+ gdk_device_get_position_double (device, screen, &tmp_x, &tmp_y);
+ if (x)
+ *x = round (tmp_x);
+ if (y)
+ *y = round (tmp_y);
+}
+
+
+/**
+ * gdk_device_get_window_at_position_double:
* @device: pointer #GdkDevice to query info to.
* @win_x: (out) (allow-none): return location for the X coordinate of the device location,
* relative to the window origin, or %NULL.
* @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
* relative to the window origin, or %NULL.
*
- * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
- * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
+ * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y in
+ * double precision. Returns %NULL if the window tree under @device is not known to GDK (for example,
+ * belongs to another application).
*
* As a slave device coordinates are those of its master pointer, This
* function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
* Since: 3.0
**/
GdkWindow *
-gdk_device_get_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y)
+gdk_device_get_window_at_position_double (GdkDevice *device,
+ gdouble *win_x,
+ gdouble *win_y)
{
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkWindow *window;
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
/* This might need corrections, as the native window returned
may contain client side children */
if (window)
- {
- double xx, yy;
-
- window = _gdk_window_find_descendant_at (window,
- tmp_x, tmp_y,
- &xx, &yy);
- tmp_x = floor (xx + 0.5);
- tmp_y = floor (yy + 0.5);
- }
+ window = _gdk_window_find_descendant_at (window,
+ tmp_x, tmp_y,
+ &tmp_x, &tmp_y);
if (win_x)
*win_x = tmp_x;
return window;
}
+/**
+ * gdk_device_get_window_at_position:
+ * @device: pointer #GdkDevice to query info to.
+ * @win_x: (out) (allow-none): return location for the X coordinate of the device location,
+ * relative to the window origin, or %NULL.
+ * @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
+ * relative to the window origin, or %NULL.
+ *
+ * Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
+ * %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
+ *
+ * As a slave device coordinates are those of its master pointer, This
+ * function may not be called on devices of type %GDK_DEVICE_TYPE_SLAVE,
+ * unless there is an ongoing grab on them, see gdk_device_grab().
+ *
+ * Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
+ *
+ * Since: 3.0
+ **/
+GdkWindow *
+gdk_device_get_window_at_position (GdkDevice *device,
+ gint *win_x,
+ gint *win_y)
+{
+ gdouble tmp_x, tmp_y;
+ GdkWindow *window;
+
+ window =
+ gdk_device_get_window_at_position_double (device, &tmp_x, &tmp_y);
+
+ if (win_x)
+ *win_x = round (tmp_x);
+ if (win_y)
+ *win_y = round (tmp_y);
+
+ return window;
+}
+
/**
* gdk_device_get_history: (skip)
* @device: a #GdkDevice
gboolean
_gdk_device_translate_screen_coord (GdkDevice *device,
GdkWindow *window,
- gint window_root_x,
- gint window_root_y,
+ gdouble window_root_x,
+ gdouble window_root_y,
guint index_,
gdouble value,
gdouble *axis_value)
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GDK_DEVICE_GET_CLASS (device)->query_state (device,
GdkWindow *
_gdk_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
(GdkDevice *device,
gint *win_x,
gint *win_y);
+GDK_AVAILABLE_IN_3_10
+void gdk_device_get_position_double (GdkDevice *device,
+ GdkScreen **screen,
+ gdouble *x,
+ gdouble *y);
+GDK_AVAILABLE_IN_3_10
+GdkWindow *
+ gdk_device_get_window_at_position_double
+ (GdkDevice *device,
+ gdouble *win_x,
+ gdouble *win_y);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_get_history (GdkDevice *device,
GdkWindow *window,
void (* warp) (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
void (* query_state) (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
GdkGrabStatus (* grab) (GdkDevice *device,
GdkWindow *window,
guint32 time_);
GdkWindow * (* window_at_position) (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ double *win_x,
+ double *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
void (* select_window_events) (GdkDevice *device,
gboolean _gdk_device_translate_screen_coord (GdkDevice *device,
GdkWindow *window,
- gint window_root_x,
- gint window_root_y,
+ gdouble window_root_x,
+ gdouble window_root_y,
guint index,
gdouble value,
gdouble *axis_value);
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
GdkWindow * _gdk_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
#include "gdkmarshalers.h"
#include "gdkscreen.h"
+#include <math.h>
#include <glib.h>
+/* for the use of round() */
+#include "fallback-c89.c"
/**
* SECTION:gdkdisplay
{
GdkScreen *default_screen;
GdkWindow *root;
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkModifierType tmp_mask;
g_return_if_fail (GDK_IS_DISPLAY (display));
if (screen)
*screen = gdk_window_get_screen (root);
if (x)
- *x = tmp_x;
+ *x = round (tmp_x);
if (y)
- *y = tmp_y;
+ *y = round (tmp_y);
if (mask)
*mask = tmp_mask;
}
{
GdkWindow *src_toplevel, *dest_toplevel;
GdkModifierType state;
- int x, y;
+ double x, y;
if (src_window)
src_toplevel = gdk_window_get_toplevel (src_window);
src_toplevel == dest_toplevel)
{
/* Same toplevels */
- gdk_window_get_device_position (dest_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (dest_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
src_window,
dest_window,
}
else if (dest_toplevel == NULL)
{
- gdk_window_get_device_position (src_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (src_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
src_window,
NULL,
else
{
/* Different toplevels */
- gdk_window_get_device_position (src_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (src_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
src_window,
NULL,
time,
NULL,
serial, FALSE);
- gdk_window_get_device_position (dest_toplevel,
- device,
- &x, &y, &state);
+ gdk_window_get_device_position_double (dest_toplevel,
+ device,
+ &x, &y, &state);
_gdk_synthesize_crossing_events (display,
NULL,
dest_window,
GdkModifierType *state_out)
{
GdkWindow *pointer_window;
- int x, y;
+ gdouble x, y;
GdkModifierType state;
pointer_window = _gdk_device_window_at_position (device, &x, &y, &state, TRUE);
GDK_WINDOW_TYPE (pointer_window) == GDK_WINDOW_FOREIGN))
pointer_window = NULL;
- *x_out = x;
- *y_out = y;
+ *x_out = round (x);
+ *y_out = round (y);
*state_out = state;
return pointer_window;
cairo_region_t *region);
GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
- int x, int y);
+ double x, double y);
GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
double x, double y,
double *found_x,
GdkDevice *device,
GdkDevice *source_device,
GdkCrossingMode mode,
- gint toplevel_x,
- gint toplevel_y,
+ gdouble toplevel_x,
+ gdouble toplevel_y,
GdkModifierType mask,
guint32 time_,
GdkEvent *event_in_queue,
static gboolean
gdk_offscreen_window_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkOffscreenWindow *offscreen;
- int tmpx, tmpy;
+ double tmpx, tmpy;
double dtmpx, dtmpy;
GdkModifierType tmpmask;
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (offscreen->embedder != NULL)
{
- gdk_window_get_device_position (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
+ gdk_window_get_device_position_double (offscreen->embedder, device, &tmpx, &tmpy, &tmpmask);
from_embedder (window,
tmpx, tmpy,
&dtmpx, &dtmpy);
- tmpx = floor (dtmpx + 0.5);
- tmpy = floor (dtmpy + 0.5);
+ tmpx = dtmpx;
+ tmpy = dtmpy;
}
if (x)
- *x = tmpx;
+ *x = round (tmpx);
if (y)
- *y = tmpy;
+ *y = round (tmpy);
if (mask)
*mask = tmpmask;
return TRUE;
}
/**
- * gdk_window_get_device_position:
+ * gdk_window_get_device_position_double:
* @window: a #GdkWindow.
* @device: pointer #GdkDevice to query to.
* @x: (out) (allow-none): return location for the X coordinate of @device, or %NULL.
* @y: (out) (allow-none): return location for the Y coordinate of @device, or %NULL.
* @mask: (out) (allow-none): return location for the modifier mask, or %NULL.
*
- * Obtains the current device position and modifier state.
+ * Obtains the current device position in doubles and modifier state.
* The position is given in coordinates relative to the upper left
* corner of @window.
*
* Return value: (transfer none): The window underneath @device (as with
* gdk_device_get_window_at_position()), or %NULL if the window is not known to GDK.
*
- * Since: 3.0
+ * Since: 3.10
**/
GdkWindow *
-gdk_window_get_device_position (GdkWindow *window,
- GdkDevice *device,
- gint *x,
- gint *y,
- GdkModifierType *mask)
+gdk_window_get_device_position_double (GdkWindow *window,
+ GdkDevice *device,
+ double *x,
+ double *y,
+ GdkModifierType *mask)
{
- gint tmp_x, tmp_y;
+ gdouble tmp_x, tmp_y;
GdkModifierType tmp_mask;
gboolean normal_child;
return NULL;
}
+/**
+ * gdk_window_get_device_position:
+ * @window: a #GdkWindow.
+ * @device: pointer #GdkDevice to query to.
+ * @x: (out) (allow-none): return location for the X coordinate of @device, or %NULL.
+ * @y: (out) (allow-none): return location for the Y coordinate of @device, or %NULL.
+ * @mask: (out) (allow-none): return location for the modifier mask, or %NULL.
+ *
+ * Obtains the current device position and modifier state.
+ * The position is given in coordinates relative to the upper left
+ * corner of @window.
+ *
+ * Use gdk_window_get_device_position_double() if you need subpixel precision.
+ *
+ * Return value: (transfer none): The window underneath @device (as with
+ * gdk_device_get_window_at_position()), or %NULL if the window is not known to GDK.
+ *
+ * Since: 3.0
+ **/
+GdkWindow *
+gdk_window_get_device_position (GdkWindow *window,
+ GdkDevice *device,
+ gint *x,
+ gint *y,
+ GdkModifierType *mask)
+{
+ gdouble tmp_x, tmp_y;
+
+ window = gdk_window_get_device_position_double (window, device,
+ &tmp_x, &tmp_y, mask);
+ if (x)
+ *x = round (tmp_x);
+ if (y)
+ *y = round (tmp_y);
+
+ return window;
+}
+
/**
* gdk_get_default_root_window:
*
GdkWindow *
_gdk_window_find_child_at (GdkWindow *window,
- int x,
- int y)
+ double x,
+ double y)
{
GdkWindow *sub;
double child_x, child_y;
GdkWindow *subwindow,
GdkDevice *device,
GdkDevice *source_device,
- gint toplevel_x,
- gint toplevel_y,
+ gdouble toplevel_x,
+ gdouble toplevel_y,
GdkModifierType mask,
guint32 time_,
GdkEvent *event_in_queue,
GdkDevice *device,
GdkDevice *source_device,
GdkCrossingMode mode,
- gint toplevel_x,
- gint toplevel_y,
+ double toplevel_x,
+ double toplevel_y,
GdkModifierType mask,
guint32 time_,
GdkEvent *event_in_queue,
gint *x,
gint *y,
GdkModifierType *mask);
+GDK_AVAILABLE_IN_3_10
+GdkWindow * gdk_window_get_device_position_double (GdkWindow *window,
+ GdkDevice *device,
+ gdouble *x,
+ gdouble *y,
+ GdkModifierType *mask);
GDK_AVAILABLE_IN_ALL
GdkWindow * gdk_window_get_parent (GdkWindow *window);
GDK_AVAILABLE_IN_ALL
gint *root_y);
gboolean (* get_device_state) (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask);
gboolean (* begin_paint_region) (GdkWindow *window,
const cairo_region_t *region);
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_quartz_device_core_grab (GdkDevice *device,
GdkWindow *window,
static void gdk_quartz_device_core_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_quartz_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_quartz_device_core_select_window_events (GdkDevice *device,
static void
gdk_quartz_device_core_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
CGDisplayMoveCursorToPoint (CGMainDisplayID (), CGPointMake (x, y));
}
static GdkWindow *
gdk_quartz_device_core_query_state_helper (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *toplevel;
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindow *found_window;
static GdkWindow *
gdk_quartz_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
static GdkWindow *
gdk_window_quartz_get_device_state_helper (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
NSPoint point;
static gboolean
gdk_window_quartz_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
return gdk_window_quartz_get_device_state_helper (window,
gdouble *axes,
GdkModifierType *mask)
{
- gint x_int, y_int;
+ gdouble x, y;
- gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
+ gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
- axes[0] = x_int;
- axes[1] = y_int;
+ axes[0] = x;
+ axes[1] = y;
}
}
static void
gdk_wayland_device_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
}
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWaylandDeviceData *wd;
static GdkWindow *
gdk_wayland_device_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
static void
output_handle_scale(void *data,
struct wl_output *wl_output,
- uint32_t factor)
+ int32_t factor)
{
GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)data;
static gboolean
gdk_window_wayland_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
gboolean return_val;
GdkWindow *window,\r
GdkWindow **root_window,\r
GdkWindow **child_window,\r
- gint *root_x,\r
- gint *root_y,\r
- gint *win_x,\r
- gint *win_y,\r
+ gdouble *root_x,\r
+ gdouble *root_y,\r
+ gdouble *win_x,\r
+ gdouble *win_y,\r
GdkModifierType *mask);\r
static GdkGrabStatus gdk_device_virtual_grab (GdkDevice *device,\r
GdkWindow *window,\r
static void gdk_device_virtual_ungrab (GdkDevice *device,\r
guint32 time_);\r
static GdkWindow * gdk_device_virtual_window_at_position (GdkDevice *device,\r
- gint *win_x,\r
- gint *win_y,\r
+ gdouble *win_x,\r
+ gdouble *win_y,\r
GdkModifierType *mask,\r
gboolean get_toplevel);\r
static void gdk_device_virtual_select_window_events (GdkDevice *device,\r
GdkWindow *window,\r
GdkWindow **root_window,\r
GdkWindow **child_window,\r
- gint *root_x,\r
- gint *root_y,\r
- gint *win_x,\r
- gint *win_y,\r
+ gdouble *root_x,\r
+ gdouble *root_y,\r
+ gdouble *win_x,\r
+ gdouble *win_y,\r
GdkModifierType *mask)\r
{\r
GdkDeviceVirtual *virtual = GDK_DEVICE_VIRTUAL (device);\r
\r
static GdkWindow *\r
gdk_device_virtual_window_at_position (GdkDevice *device,\r
- gint *win_x,\r
- gint *win_y,\r
+ gdouble *win_x,\r
+ gdouble *win_y,\r
GdkModifierType *mask,\r
gboolean get_toplevel)\r
{\r
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_win32_grab (GdkDevice *device,
GdkWindow *window,
static void gdk_device_win32_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_device_win32_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_win32_select_window_events (GdkDevice *device,
static void
gdk_device_win32_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
}
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
POINT point;
static GdkWindow *
gdk_device_win32_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_device_wintab_grab (GdkDevice *device,
GdkWindow *window,
static void gdk_device_wintab_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_device_wintab_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_device_wintab_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkDeviceWintab *device_wintab;
static GdkWindow *
gdk_device_wintab_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
static gboolean
gdk_window_win32_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *child;
#include "config.h"
+
#include "gdkx11device-core.h"
#include "gdkdeviceprivate.h"
#include "gdkprivate-x11.h"
#include "gdkasync.h"
+#include <math.h>
+
+/* for the use of round() */
+#include "fallback-c89.c"
+
struct _GdkX11DeviceCore
{
GdkDevice parent_instance;
GdkCursor *cursor);
static void gdk_x11_device_core_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
static void gdk_x11_device_core_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_x11_device_core_grab (GdkDevice *device,
GdkWindow *window,
static void gdk_x11_device_core_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_x11_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_x11_device_core_select_window_events (GdkDevice *device,
gdouble *axes,
GdkModifierType *mask)
{
- gint x_int, y_int;
+ gdouble x, y;
- /* TODO: This rounds the coords, should use double */
- gdk_window_get_device_position (window, device, &x_int, &y_int, mask);
+ gdk_window_get_device_position_double (window, device, &x, &y, mask);
if (axes)
{
- axes[0] = x_int;
- axes[1] = y_int;
+ axes[0] = x;
+ axes[1] = y;
}
}
static void
gdk_x11_device_core_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
Display *xdisplay;
Window dest;
dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
- x * GDK_X11_SCREEN (screen)->window_scale,
- y * GDK_X11_SCREEN (screen)->window_scale);
+ round (x * GDK_X11_SCREEN (screen)->window_scale),
+ round (y * GDK_X11_SCREEN (screen)->window_scale));
}
static void
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
- *root_x = xroot_x / impl->window_scale;
+ *root_x = (double)xroot_x / impl->window_scale;
if (root_y)
- *root_y = xroot_y / impl->window_scale;
+ *root_y = (double)xroot_y / impl->window_scale;
if (win_x)
- *win_x = xwin_x / impl->window_scale;
+ *win_x = (double)xwin_x / impl->window_scale;
if (win_y)
- *win_y = xwin_y / impl->window_scale;
+ *win_y = (double)xwin_y / impl->window_scale;
if (mask)
*mask = xmask;
static GdkWindow *
gdk_x11_device_core_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (win_x)
- *win_x = (window) ? xwin_x / impl->window_scale : -1;
+ *win_x = (window) ? (double)xwin_x / impl->window_scale : -1;
if (win_y)
- *win_y = (window) ? xwin_y / impl->window_scale : -1;
+ *win_y = (window) ? (double)xwin_y / impl->window_scale : -1;
if (mask)
*mask = xmask;
#include <X11/Xutil.h>
#include <X11/extensions/XInput2.h>
+#include <math.h>
+
+/* for the use of round() */
+#include "fallback-c89.c"
typedef struct _ScrollValuator ScrollValuator;
GdkCursor *cursor);
static void gdk_x11_device_xi2_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y);
+ gdouble x,
+ gdouble y);
static void gdk_x11_device_xi2_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_x11_device_xi2_grab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_x11_device_xi2_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_x11_device_xi2_select_window_events (GdkDevice *device,
static void
gdk_x11_device_xi2_warp (GdkDevice *device,
GdkScreen *screen,
- gint x,
- gint y)
+ gdouble x,
+ gdouble y)
{
GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device);
Window dest;
device_xi2->device_id,
None, dest,
0, 0, 0, 0,
- x * GDK_X11_SCREEN(screen)->window_scale,
- y * GDK_X11_SCREEN(screen)->window_scale);
+ round (x * GDK_X11_SCREEN(screen)->window_scale),
+ round (y * GDK_X11_SCREEN(screen)->window_scale));
}
static void
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
- gint *root_x,
- gint *root_y,
- gint *win_x,
- gint *win_y,
+ gdouble *root_x,
+ gdouble *root_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
*child_window = gdk_x11_window_lookup_for_display (display, xchild_window);
if (root_x)
- *root_x = (gint) (xroot_x / impl->window_scale);
+ *root_x = xroot_x / impl->window_scale;
if (root_y)
- *root_y = (gint) (xroot_y / impl->window_scale);
+ *root_y = xroot_y / impl->window_scale;
if (win_x)
- *win_x = (gint) (xwin_x / impl->window_scale);
+ *win_x = xwin_x / impl->window_scale;
if (win_y)
- *win_y = (gint) (xwin_y / impl->window_scale);
+ *win_y = xwin_y / impl->window_scale;
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
static GdkWindow *
gdk_x11_device_xi2_window_at_position (GdkDevice *device,
- gint *win_x,
- gint *win_y,
+ gdouble *win_x,
+ gdouble *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (win_x)
- *win_x = (window) ? (gint) (xwin_x / impl->window_scale) : -1;
+ *win_x = (window) ? (xwin_x / impl->window_scale) : -1;
if (win_y)
- *win_y = (window) ? (gint) (xwin_y / impl->window_scale) : -1;
+ *win_y = (window) ? (xwin_y / impl->window_scale) : -1;
if (mask)
*mask = _gdk_x11_device_xi2_translate_state (&mod_state, &button_state, &group_state);
static gboolean
gdk_window_x11_get_device_state (GdkWindow *window,
GdkDevice *device,
- gint *x,
- gint *y,
+ gdouble *x,
+ gdouble *y,
GdkModifierType *mask)
{
GdkWindow *child;